Pular para o conteúdo principal

!warn"Notice: This documentation is currently being rewritten. It is based on an older version of the previous GitHub documentation, so it may be confusing or unclear."

disfox + discord.js — Creating an Application

In this example, we will learn how to create and configure your application using disfox + discord.js.

With just one instance of Application, you get:

  • Simplified event system
  • Automatic command registration
  • Scalable organization
  • Other useful features

1. Required Imports

First, import discord.js and disfox.

import { Client, GatewayIntentBits } from "discord.js";
import { Application } from "disfox";

2. Creating the client with discord.js

const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages
]
});

3. Creating the Application instance

Now we create an instance of the Application class, which represents both the client and the bot application.

const myBot = new Application({
client: client,
token: "MyApplication_TOKEN"
});

Parameters

ParameterDescription
clientInstance of Client created with discord.js
tokenDiscord application token

4. Connecting the application

Log in with the bot.

await myBot.connect();

If everything is correct, the bot will be online.